package com.content.Controller.artist;

import com.common.Entity.Result;
import com.content.Entity.artist.Artist;
import com.content.Service.artist.ArtistService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/artist")
public class ArtistController {
    @Autowired
    private ArtistService artistService;

    @GetMapping("/getArtistList")
    public Result getArtistList(@RequestParam Integer pageNum,
                                @RequestParam Integer pageSize,
                                @RequestParam(required = false) String artistName,
                                @RequestParam(required = false) String categoryId,
                                @RequestParam(required = false) String schoolId) {
        PageInfo<Artist> pageInfo = artistService.getArtistList(pageNum, pageSize, artistName, categoryId, schoolId);
        return Result.success(pageInfo);
    }
    @GetMapping("/getArtists")
    public Result getArtists() {
        return Result.success(artistService.getArtists());
    }

    @GetMapping("/getArtistDetail/{artistId}")
    public Result getArtistDetail(@PathVariable("artistId") String artistId) {
        return Result.success(artistService.getArtistById(artistId));
    }

    @GetMapping("/getArtistByCategoryId/{categoryId}")
    public Result getArtistByCategoryId(@PathVariable("categoryId") String categoryId) {
        return Result.success(artistService.getArtistsByCategoryId(categoryId));
    }
    @GetMapping("/getArtistWorks/{artistId}")
    public Result getArtistWorks(@PathVariable("artistId") String artistId) {
        return Result.success(artistService.getArtistWorks(artistId));
    }
    @GetMapping("/getArtistFeatures/{artistId}")
    public Result getArtistFeatures(@PathVariable("artistId") String artistId) {
        return Result.success(artistService.getArtistFeatures(artistId));
    }
    @GetMapping("/getArtistHistories/{artistId}")
    public Result getArtistHistories(@PathVariable("artistId") String artistId) {
        return Result.success(artistService.getArtistHistories(artistId));
    }

    @PostMapping("/addArtist")
    public Result addArtist(@RequestBody Artist artist) {
        artistService.addArtist(artist);
        return Result.success();
    }

    @PutMapping("/updateArtist")
    public Result updateArtist(@RequestBody Artist artist) {
        artistService.updateArtist(artist);
        return Result.success();
    }

    @DeleteMapping("/deleteArtist/{artistId}")
    public Result deleteArtist(@PathVariable("artistId") String artistId) {
        artistService.deleteArtist(artistId);
        return Result.success();
    }
}
